package com.idp.web.service.impl;

import com.idp.common.persistence.Page;
import com.idp.common.util.ResourceUtils;
import com.idp.web.dao.UserDao;
import com.idp.web.entity.User;
import com.idp.web.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户service实现类
 *
 * @author xubinren
 * @version 1.0
 * @date 2018/2/27
 */
@Service("userService")
public class UserServiceImpl implements IUserService {

    @Resource
    private UserDao userDao;

    @Override
    public Page<User> findByPage(User user, Page<User> page) {

        page.setResult(userDao.find(user, page));

        return page;
    }

    @Override
    public List<User> findBySearch(User user) {

        return userDao.find(user);
    }

    @Override
    public User getById(String id) {
        return userDao.getById(id);
    }

    @Override
    public void add(User user) {
        user.setId(ResourceUtils.getUUID());
        userDao.add(user);
    }

    @Override
    public void update(User user) {

        userDao.update(user);
    }

    @Override
    public void delete(String id) {

        userDao.delete(id);
    }

}